package org.ws.lifebacklog.util;

import android.util.Log;

/**
 * Easy customizable(writing to file,send email reports) logger. You can add filter to the logcat view with tag
 * "org.jazzteam.odin" and it will be displaying only application log.
 * 
 * @author sergey.valuy
 * */
public class Logger {

	private static final String APP_TAG = "org.ws.android";

	public static void w(Class<?> clazz, String msg) {
		w(clazz, msg, null);
	}

	public static void e(Class<?> clazz, String msg) {
		e(clazz, msg, null);
	}

	public static void e(Class<?> clazz, Throwable tr) {
		e(clazz, clazz.getSimpleName() + " : " + tr.getMessage(), tr);
	}

	/** System calls */
	public static void e(Class<?> clazz, String msg, Throwable tr) {
		if (Log.isLoggable(APP_TAG, Log.ERROR)) {
			Log.e(APP_TAG, clazz.getSimpleName() + " : " + msg, tr);
		}
		// writeToLogFile(msg, tr);
	}

	public static void w(Class<?> clazz, String msg, Throwable tr) {
		if (Log.isLoggable(APP_TAG, Log.WARN)) {
			Log.w(APP_TAG, clazz.getSimpleName() + " : " + msg, tr);
		}
	}

	public static void i(Class<?> clazz, String msg) {
		if (Log.isLoggable(APP_TAG, Log.INFO)) {
			Log.i(APP_TAG, clazz.getSimpleName() + " : " + msg);
		}
	}

	public static void d(Class<?> clazz, String msg) {
		if (Log.isLoggable(APP_TAG, Log.DEBUG)) {
			Log.d(APP_TAG, clazz.getSimpleName() + " : " + msg);
		}
	}
}
